package com.xiaoshuidi.cloud.module.report.convert.finance;

import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.ContractRoomDepositExportRespVO;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.HouseOwnerDepositExportRespVO;
import com.xiaoshuidi.cloud.module.report.dal.DO.report.ReportContractRoomDepositDO;
import com.xiaoshuidi.cloud.module.report.dal.DO.report.ReportHouseOwnerDepositDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 权责收入 转换类
 */
@Mapper
public interface ReportHouseOwnerDepositConvert {

    ReportHouseOwnerDepositConvert INSTANCE = Mappers.getMapper(ReportHouseOwnerDepositConvert.class);


    @Mapping(target = "remainAmount", expression = "java((dto.getOutflowDeposit()!=null?dto.getOutflowDeposit():java" +
            ".math" +
            ".BigDecimal.ZERO).subtract(dto.getInflowDeposit()!=null?dto.getInflowDeposit(): java.math.BigDecimal" +
            ".ZERO))")
    @Mapping(target = "contractCycle", expression = "java(dto.getStartTime()+\" ~ \"+dto.getEndTime())")
    @Mapping(target = "inflowDeposit", expression = "java(dto.getInflowDeposit()!=null?dto.getInflowDeposit(): java" +
            ".math.BigDecimal" +
            ".ZERO)")
    @Mapping(target = "outflowDeposit", expression = "java(dto.getOutflowDeposit()!=null?dto.getOutflowDeposit():java" +
            ".math" +
            ".BigDecimal.ZERO)")
    HouseOwnerDepositExportRespVO convert(ReportHouseOwnerDepositDO dto);

    PageResult<HouseOwnerDepositExportRespVO> convertPageResult(PageResult<ReportHouseOwnerDepositDO> dto);

    List<HouseOwnerDepositExportRespVO> convertPageList(List<ReportHouseOwnerDepositDO> dto);


}
